home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / programr / faultw / fault.h < prev    next >
C/C++ Source or Header  |  1992-03-30  |  2KB  |  78 lines

  1. /*
  2.  * FAULT.H
  3.  *
  4.  * Definitions and function prototypes for Fault.
  5.  *
  6.  * Copyright(c) Microsoft Corp. 1992 All Rights Reserved
  7.  */
  8.  
  9.  
  10. /*
  11.  * Resource idetifiers and menu ID values.
  12.  */
  13.  
  14. #define IDR_ICON    1
  15. #define IDR_MENU    1
  16.  
  17. #define IDM_EXDIVIDEBYZERO  100
  18. #define IDM_EXGPFAULT       101
  19.  
  20.  
  21.  
  22.  
  23. /*
  24.  * Structure holding the "global" variables.  Creating a structure with
  25.  * has several advantages over separately declaring each field as a
  26.  * global:
  27.  *  1.  Keep source files clean.
  28.  *  2.  Eliminates need for many "extern" declarations.
  29.  *  3.  A single pointer to this structure can be passed throughout
  30.  *      the application, hiding the fact that it's global.
  31.  *  4.  Allows the variables to be allocated dynamically or from
  32.  *      different memory than the application's stack.
  33.  *  5.  Any reference to these variables will have a pointer or
  34.  *      structure dereference, which points to where the variable
  35.  *      actually is defined.  Separate globals are not distinguishable
  36.  *      from locals, making code harder to read.
  37.  */
  38.  
  39. typedef struct
  40.     {
  41.     HWND            hWnd;               //Top-level application window.
  42.     HANDLE          hInst;              //Application instance handle.
  43.     FARPROC         pfnInt;             //GP Fault Handler
  44.     } GLOBALS;
  45.  
  46. typedef GLOBALS FAR * LPGLOBALS;
  47.  
  48.  
  49. //External:
  50. extern LPGLOBALS     pGlob;
  51. extern CATCHBUF      cbEx;
  52. extern LPCATCHBUF    pcbEx;
  53. extern WORD          wException;
  54.  
  55.  
  56. /*
  57.  * Flag values to store in the wException global variable that tells
  58.  * the handler what type of exceptions we specifically want.
  59.  */
  60.  
  61. #define EXCEPTION_NONE          0x0000      //Turns handling off.
  62. #define EXCEPTION_DIVIDEBYZERO  0x0001
  63. #define EXCEPTION_GPFAULT       0x0002
  64. #define EXCEPTION_ALL           0x0003      //Looks for all exceptions above.
  65.  
  66.  
  67. /*
  68.  * Function prototypes.
  69.  */
  70.  
  71. //FAULT.C
  72. LONG     FAR PASCAL FaultWndProc(HWND, UINT, UINT, LONG);
  73. BOOL     FAR PASCAL FPerformCalculation(void);
  74. HANDLE   FAR PASCAL HAllocateNumbers(void);
  75.  
  76. //HANDLER.ASM
  77. void     FAR PASCAL ExceptionHandler(void);
  78.